package C10_15_ReplaceExceptionWithTest.after_refactor;

import C10_15_ReplaceExceptionWithTest.Resource;

import java.util.EmptyStackException;
import java.util.Stack;

public class ResourcePool {
    Stack _available;
    Stack _allocated;


    Resource getResource() {
        Resource result;
        if (_available.isEmpty()) {
            result = new Resource();
        } else {
            result  = (Resource) _available.pop();
        }
        _allocated.push(result);
        return result;
    }
}
